# TS平台 班级详情
import unittest
from time import sleep

from Common.base_test import BaseTestClass
from PageObjects.login.login_page import LoginPage
from PageObjects.TS.ts_class_detail_page import TsClassPage
from TestDatas.login_datas import ts_user_data
from TestDatas.CommDatas import web_login_url
from TestDatas.TsDatas.ts_class_datas import *
from Common.BeautifulReport import BeautifulReport
from Common.dir_config import *


class TsClassDetail(BaseTestClass):
    """TS平台班级详情"""
    def test_0_1_go_to_ar_question_bank_management(self):
        """OA登录并跳转AR"""
        self.driver.get(web_login_url)
        self.lp = LoginPage(self.driver)
        # 步骤：登录页面-登录操作
        self.lp.login(ts_user_data["user"], ts_user_data["pwd"])
        sleep(3)
        self.assertTrue(self.lp.assert_welcome())
        self.lp.go_ts()
        self.lp.switch_window("教学服务平台")
        sleep(10)

    def test_0_2_class_lst(self):
        """ts我的班级-列表"""
        self.tp = TsClassPage(self.driver)
        self.tp.go_my_class_nav()
        class_lst_data = self.tp.my_class_lst()
        self.assertIn(class_finish_lst_name, class_lst_data, "列表中不包含期望数据")

    def test_0_3_class_detail(self):
        """班级详情"""
        self.tp = TsClassPage(self.driver)
        detail_data = self.tp.my_class_detail()
        self.assertIn(class_info_expect, detail_data['class_info'], "基本信息未包含期望数据")
        self.assertIn(course_lst_expect, detail_data['course_lst'], "全部课时未包含期望数据")
        self.assertIn(student_body_expect, detail_data['student_body'], "学员列表未包含期望数据")
        self.assertIn(student_info_expect, detail_data['student_info'], "当前班级学员未包含期望数据")
        job_completion_data = self.tp.job_completion()
        self.assertIn(job_completion_expect, job_completion_data, "作业完成情况未包含预期数据")


if __name__ == '__main__':
    # unittest.main()
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(TsClassDetail))
    result = BeautifulReport(suite)
    result.report(filename="TS班级测试报告", description='TS班级详情', log_path=htmlreport_dir)
